<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title></title>
	<%@include file="/view/resource.jsp" %>
	<link rel="stylesheet" type="text/css" href="${ctx}/css/base.css">
	<link rel="stylesheet" href="${ctx}/static/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="${ctx}/static/plugins/ztree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="${ctx}/static/plugins/ztree/js/jquery.ztree.excheck.js"></script>
</head>
<body>
<style type="text/css">
	.editTable {
		margin: 50px auto 20px;
	}

	.editTable td {
		padding: 5px;;
	}

	.buttonSend {
		background-color: #009688;
		color: #fff;
		cursor: pointer;
		height: 35px;
		border: none;
		min-width: 60px;
		float: right;
	}

	.buttonSend:hover {
		color: #000;
	}

	.depInputClass {
		border: 1px solid #ffa8a8;
		background-color: #fff3f3;
	}

	.commandMsg {
		color: #330099;
		font-weight: bold;
		font-size: 14px !important;
		background-repeat: no-repeat;
	}

	.buttonSendWait {
		background-color: #ddd;
		color: #fff;
		height: 35px;
		border: none;
		min-width: 60px;
		float: right;
	}
</style>
<body>
<div class="topjui-layout" data-options="fit:true">
	<div data-options="region:'west',split:false,width:400,border:false">
		<div title="" style="padding: 3px">
			<span style="margin-left: 100px;font-size:14px;color: #330099; ">指挥卡树形</span>
			<div id="p" style="margin-bottom: 5px">
				<select class="topjui-combobox" name="filterType" id="filterType" style="width: 180px;"
				        data-options="panelHeight:105,value:'0'">
					<option value="设备号">设备号</option>
					<option value="显示名称">显示名称</option>
					<option value="分组名称">分组名称</option>
				</select>
				<input id="searchBox" class="topjui-searchbox"
				       style="width: 180px"/>
			</div>
			<ul id="deviceTree" class="ztree">
			</ul>
		</div>
	</div>
	<div data-options="region:'center'">
		<div class="topjui-layout" data-options="fit:true">
			<div id="centerLayout" class="topjui-layout" data-options="fit:true">
				<div data-options="region:'center',border:true">
					<form id="entityForm" name="entityForm" action="${ctx}/terminalCommand/sendShortMessageBatch"
					      method="POST">
						<input type="hidden" name="deviceIds" id="deviceIds">
						<input type="hidden" name="isAnnouncement" id="isAnnouncement" value="1">
						<table class="editTable">
							<tr>
								<td class="label" style="width: 80px;min-width: 80px;">报文短信内容</td>
								<td colspan="3">  <textarea style="width: 500px;height:200px;" id="cmdContent"
								                            maxlength="30"
								                            class="topjui-ueditor" name="cmdContent"></textarea>
								</td>
							</tr>
							<br/>
							<tr>
								<td class="label" style="width: 60px;min-width: 60px;"></td>
								<td colspan="3" style="font-weight: bold;">
									<input id="btnSend" style="width: 100px;"
									       class="buttonSend"
									       type="button"
									       value="发送"
									       onclick="send();"/>
								</td>
							</tr>

						</table>
					</form>
					<span class="commandMsg" id="msgSuccess" style="display:inline-block;margin: 10px 0 0 20px;"></span>
					<br/>
					<span class="commandMsg" id="msgFail" style="display:inline-block;margin: 10px 0 0 20px;"></span>
				</div>
				<div data-options="region:'south',split:true,border:true,collapsed:true" style="height:300px;">
					<div id="realDataTab" class="topjui-tabs"
					     data-options="fit:true,border:false,plain:true,tools:'#tab-tools'">
						<div title="绑定指挥卡数据" style="padding:0px">
							<div id="bindGridToolbar" style=" margin :0px; padding :5px;">
								设备号：
								<input id="simNo" name="simNo" class="topjui-textbox" type="text"
								       style="width:140px;"/>
								<input type="hidden" id="parentSims" name="parentSims">
								<a id="btnQueryData" href="#" class="topjui-menubutton"
								   data-options="iconCls:'fa fa-search',btnCls:'topjui-btn'">查询</a>

							</div>
							<div id="bindDataGrid"></div>
						</div>
					</div>
					<div id="tab-tools">
						<a href="javascript:void(0)" class="topjui-menubutton"
						   data-options="plain:true,iconCls:'fa fa-angle-double-down'"
						   onclick="hideRealDataTab()"></a>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="${ctx}/js/message/treeinfo.js"></script>
<script type="text/javascript" src="${ctx}/js/common/package.js"></script>
<script type="text/javascript" src="${ctx}/js/common/base.js?v=11"></script>
<script type="text/javascript" src="${ctx}/js/common/DataGrid.js"></script>
<script type="text/javascript" src="${ctx}/js/message/information.js"></script>
<script type="text/javascript" src="${ctx}/js/terminalCommand/sendMessageWait.js"></script>
<!--终端命令结果查询-->
<script type="text/javascript" charset="utf-8">

	function send() {
		var data = {};
		var treeObj = $.fn.zTree.getZTreeObj("deviceTree");
		var nodes = treeObj.getCheckedNodes(true);

		if (nodes.length == 0) {
			$('#msgSuccess').html('请勾选需要发送的指挥卡.');
			return false;
		}

		if (nodes && nodes.length) {
			var selectDeviceIds = "";
			for (var i = 0, len = nodes.length; i < len; i++) {
				var node = nodes[i];
				if (typeof (node.children) == "undefined" && node.id.indexOf("v") == 0) {
					nodeId = node.id.substring(1, node.id.length)
					selectDeviceIds += nodeId + ",";
				}
			}
			if (selectDeviceIds != "") {
				selectDeviceIds = selectDeviceIds.substring(0, selectDeviceIds.length - 1);
			}
			$("#deviceIds").val(selectDeviceIds);
		}
		if ($("#deviceIds").val() == "") {
			$('#msgSuccess').html('请勾选需要发送的指挥卡.');
			return false;
		}
		var cmdContent = $.trim($('#cmdContent').val());
		if (cmdContent == '') {
			$('#msgSuccess').html('请输入内容!');
			return;
		}
		if ($("#entityForm").form('validate')) {
			Bdth.submitForm($("#entityForm"), data, function (result) {
				$("#msgSuccess").html(result.msgSuccess);
				$("#msgFail").html(result.msgFail);
				SendMessageWait.settime($("#btnSend"));
			});
		}
	}
</script>

<script type="text/javascript">
	$(function () {
		//创建设备树
		var deviceTreeId = "deviceTree";
		//设备
		DeviceTree.createTree(deviceTreeId, 0);

		$('#searchBox').searchbox({
			searcher: function (value, name) {
				var filterTypeValue = $("#filterType").combobox('getText');
				var filterType = "";
				if ("设备号" == filterTypeValue) {
					filterType = 0;
				}
				if ("显示名称" == filterTypeValue) {
					filterType = 1;
				}
				if ("分组名称" == filterTypeValue) {
					filterType = 2;
				}
				DeviceTree.Treefilter(filterType, value);
			},
			prompt: '条件查询',
		});
		$('#filterType').combobox("setValue", "设备号");
	})

	function hideRealDataTab() {
		$('#centerLayout').layout('collapse', 'south');
	}

	BindGrid.create();
</script>
</body>
</html>
